package top.gbyun.engine.actor;

import akka.actor.ActorRef;
import akka.event.Logging;
import akka.event.LoggingAdapter;
import top.gbyun.core.ActorSystemContext;
import top.gbyun.core.entity.FlowInfo;
import top.gbyun.core.msg.flow.FlowStartMsg;

import java.util.HashMap;
import java.util.Map;

/**
 * @author gengbin
 * @date 2024-12-25-11:18
 */
public class AppActor extends ContextAwareActor {

    private boolean initialize;

    private final Map<String, ActorRef> flowActors;

    private final Map<String, FlowInfo> flowInfoMap;

    private final LoggingAdapter logger = Logging.getLogger(getContext().system(), this);

    public AppActor(ActorSystemContext systemContext, boolean initialize, Map<String, ActorRef> flowActors, Map<String, FlowInfo> flowInfoMap) {
        super(systemContext);
        this.initialize = initialize;
        this.flowActors = new HashMap<>();
        this.flowInfoMap = new HashMap<>();
    }

    @Override
    public void preStart() throws Exception {
        // 初始化所有流程
        if(!initialize){
            initFlowActors();
            initialize=true;
        }

        logger.info("AppActor已启动");
    }

    private void initFlowActors() {

    }


    @Override
    public Receive createReceive() {
        return receiveBuilder()
                .match(FlowStartMsg.class,s->{
                    logger.info("收到流程启动消息");

                })
                .build();
    }


}
